package org.youyun56.gpsserver.command;

import org.youyun56.gpsserver.CacheFactory;
import org.youyun56.gpsserver.Task;
import org.youyun56.gpsserver.common.Page;
import org.youyun56.gpsserver.common.YouyunMap;

/**
 * @author Kingsley
 * @date 2011-12-13 下午03:45:35
 * 
 *       input:page pagesize city
 */
public class GetGoodExecutor extends Task {

    @Override
    public Object execute() {
        YouyunMap map = command.getParameters();
        Integer pageSize = map.getInt("pagesize");
        Integer pageIndex = map.getInt("page");
        Page page = new Page(1);
        if (pageIndex != null) {
            page.setPageIndex(pageIndex);
        }
        if (pageSize != null) {
            page.setPageSize(pageSize);
        } else {
            page.setPageSize(30);
        }
        command.setPage(page);
        return CacheFactory.instance.getGoodCache(command.getParameters().getInt("city"), page);
    }

}
